#ifndef __VENTANA__H__
#define __VENTANA__H__

#include <QWidget>
#include <QColor>

class QPaintEvent;
class QResizeEvent;
class QKeyEvent;

class Ventana : public QWidget {
	public:
		Ventana( QWidget *parent = 0 );
		
	protected:
		void paintEvent( QPaintEvent * );
		void resizeEvent( QResizeEvent * );
		void keyPressEvent( QKeyEvent * );
	
	private:
		struct Circulo {
			float dist, radio;
			float radioIntervalo;
			mutable bool solucion; // Para cambiarlo al mismo tiempo que lo ordenamos ;-)
			
			float a() const { return dist - radioIntervalo; }
			float b() const { return dist + radioIntervalo; }
			
			bool operator<( const Circulo &otro ) const {
				solucion = otro.solucion = false;
				return a() < otro.a();
			}
			
			Circulo( float d = 10.0f, float r = 50.0f ) {
				dist = d;
				radio = r;
				radioIntervalo = 0.0f;
				solucion = false;
			}
		};
		
		struct Campo {
			int x, y;
			int l, w;
		};
		
		Campo mCampo;
		QVector< Circulo > mCirculos;
		Circulo mActual;
		bool solucionado;
		
		void calcularTamano( int ancho, int alto );
		void dibujarCirculo( QPainter &, const Circulo &, const QColor & = QColor( Qt::black ) );
		int resolver();
};

#endif